from transformers import MarianMTModel, MarianTokenizer
src = 'en'  # source language
trg = 'ROMANCE'  # target language
src_text = [
    '>>fr<< Courage is the honor of human.',
    '>>pt<< Courage is the honor of human.',
    '>>es<< Courage is the honor of human.'
]
model_name = f'D:/gitee_codes/transformer-learning/models/Helsinki-NLP/opus-mt-{src}-{trg}'
tokenizer = MarianTokenizer.from_pretrained(model_name)
model = MarianMTModel.from_pretrained(model_name)
translated = model.generate(**tokenizer.prepare_translation_batch(src_text))
print([tokenizer.decode(t, skip_special_tokens=True) for t in translated])